package com.huiquan.vocab.utils;

public class VocabUtils {

	/**
	 * 根据数据库中的例句字符串分割为界面上可展现的字符串
	 * @param sentence
	 * @return
	 */
	public static String[] getSentenceAndShowSentence(String value) {
		// 例句的分隔符
		char sentenceSegmentFlag = 3;
		// 例句的频数分割符号
		char countSegmentFlag = 4;
		String[] sentences = value.split("\\" + sentenceSegmentFlag);
		StringBuffer sentence = new StringBuffer();
		for (int i = 0; i < sentences.length; i++) {
			// 去除例句频数
			String[] sentenceAndCount = sentences[i].split("\\" + countSegmentFlag);
			sentences[i] = sentenceAndCount[0];
			sentence.append(sentences[i]);
			if (i != (sentences.length - 1)) {
				sentence.append("\n");
			}
		}
		return new String[] { sentence.toString(), sentences[0] };
	}
}
